﻿ 
function obtainGLatLng(strCommunityName)
{
    var geocoder;
    geocoder = new GClientGeocoder();
    var location = $("#province").val() + $("#city").val();
    geocoder.getLocations(location + strCommunityName, findGlatLng);
}

function findGlatLng(response)
{
    if (response || response.Status.code == 200)
    {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
        console.log(point);
        $("#txtLng").val(point.lng());
        $("#txtLat").val(point.lat());
    }
}
 
     
function getSource(strMixID, strSource)
{
    if (strSource == "BlockSource")
    {
        if ($("#ddArea").get(0).selectedIndex != 0)
        {
            $("#ddBlock").FillOptions("/Service/GetDropListSource.html?strMixID=" + strMixID + "&strSource=" + strSource, { datatype: "json", textfield: "BlockName", valuefiled: "BlockId" });
            $("#txtBlockEval").val($("#ddBlock").val());
            areaValidate();
        }
        else {
            $("#ddBlock").empty();
            $("#ddBlock").AddOption("请选择", "-1", true, 0);
            areaValidate();
        }
    }
    else {
        if ($("#ddSubway").get(0).selectedIndex != 0)
        {
            $("#ddStation").FillOptions("/Service/GetDropListSource.html?strMixID=" + strMixID + "&strSource=" + strSource, { datatype: "json", textfield: "StationTitle", valuefiled: "StationId" });
            $("#txtStationEval").val($("#ddStation").val());
            subwayValidate();
        }
        else 
        {
            $("#ddStation").empty();
            $("#ddStation").AddOption("请选择", "-1", true, 0);
            subwayValidate();
        }
    }
}
		
 
function showMsg(uploadCommodel, msg)
{
    uploadCommodel.find(".msgPanel").html(msg);
}


function showPicDiv(uploadCommodel, data, photoTypeName, needTitle, divBox, max) {
    var has = parseInt($(uploadCommodel).data("max")) - 1;
    var i = has % 4;

    if (i == 1 && has > 4) {
        var height = parseInt($(uploadCommodel).parent().prev().css("height"));
        $(uploadCommodel).parent().prev().css("height", (height + i * 130) + "px");
        $(uploadCommodel).parent().css("height", (height + i * 130) + "px");
    }

    var picDivID = photoTypeName + "_" + Math.ceil(Math.random() * 1000);
    var picDiv = '<div id="' + picDivID + '" class="housepicone">'
    	                + '<div class="housepic">'
    	                + '<img height="75" width="100" src="' + data.minPhotoUrl + '" alt="" />'
                        + '<div class="deletepic1">'
    	                + '<a onclick="deletePicDiv(\'' + picDivID + '\',\'' + divBox + '\');" href="javascript:void(0)">删除</a>'
    	                + '</div>'
    	                + '<input type="hidden" value="' + data.minPhotoUrl + '" name="' + photoTypeName + '_Min" />'
    	                + '<input type="hidden" value="' + data.maxPhotoUrl + '" name="' + photoTypeName + '_Max" />'
    	                + '</div>';
    if (needTitle) {
        picDiv = picDiv + '<div class="housepicw1"><textarea name="' + photoTypeName + '_Title">照片描述最多16个中文字</textarea><span style="color: rgb(102, 102, 102);">描述：(选填)</span><br /></div></div>';
    }
    else {
        picDiv = picDiv + '<div style="display:none;" class="housepicw1"><textarea name="' + photoTypeName + '_Title">测试隐藏内容获取</textarea><span style="color: rgb(102, 102, 102);">描述：(选填)</span><br /></div></div>';
    }

    uploadCommodel.find(".defaultPicPanel").hide();
    //uploadCommodel.find(".defaultPicPanel").remove();
    uploadCommodel.find(".commodelPanel").append(picDiv);
}



function deletePicDiv(picDivID, divBox) {
    $("#" + picDivID).parent().parent().find(".msgPanel").html("");
    $("#" + picDivID).remove();


    var has = parseInt($(divBox).data("max")) - 1;
    var i = has % 4;
    if (i == 1 && has > 3) {
        var height = parseInt($(divBox).parent().prev().css("height"));
        $(divBox).parent().prev().css("height", (height - 130) + "px");
        $(divBox).parent().css("height", (height - 130) + "px");
    }

    var total = $(divBox).data("max") - 1;
    if (total == 1) {
        $(divBox + " .defaultPicPanel").show();
    }
    $(divBox).data("max", total);
}


//